<template lang="">
	<div class="content">
		<mp-html class="ql-editor" :content="content.content" @linktap="onLinkTap" />
	</div>
</template>
<script>
import { queryInformationDetail } from '../../apis';
import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'
import { download, downloadVideo } from '../../utils/util';

export default {
	components: {
		mpHtml
	},
	data() {
		return {
			content: {},
			options: undefined
		}
	},
	onLoad(options) {
		this.options = options
		this.queryInformationDetail()
		
	},


	methods: {
		onLinkTap(ev) {
			console.log(ev);
		},
		parseRichText(content) {
			let nData=''
				
				nData = content.replace(/&lt;/g,'<')
				nData = nData.replace(/&gt;/g,'>')
				nData = nData.replace(/<video src="(.*?)fileId=(.*?)"/gi, `<video src="${downloadVideo('$2')}"`)
				nData = nData.replace(/<img(.*?)src="(.*?)fileId=(.*?)"/gi, `<img src="${download('$3')}"`)
			console.log('nData: ', nData);
			return nData
		},
		queryInformationDetail() {
			queryInformationDetail({id: this.options?.id}).then((result) => {
				
				this.content = result.data
				this.content.content = this.parseRichText(result.data.content)
				
			}).catch((err) => {
				
			});
		}
	}
}
</script>
<style lang="scss" scoped>
	.content {
		padding: 30rpx 40rpx;
	}
</style>